/*
 * Copyright 2013-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.lizemin.springaspect.controller;

import cn.hutool.core.util.StrUtil;
import com.lizemin.springaspect.entity.UserInfo;
import com.lizemin.springaspect.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("/heartBeat")
    public String heartBeat() {
        return "ok";
    }

    @GetMapping("/getUserInfo")
    public String getUserInfo(String name, String age) {
        return StrUtil.format("您的姓名是：{}, 年龄是：{}", name, age);
    }

    @PostMapping("/getUser")
    public UserInfo getUser(@RequestBody UserInfo userInfo) {
        log.info("接口中的日志");
        return userInfo;
    }

    /**
     * 获取天气的接口
     * @param location 地点
     * @return 天气
     */
    @GetMapping("/getWhether")
    public String getWhether(String location) {
        int userId = 22;
        return testService.getWhether(location, userId);
    }

}
